import { createSlice, PayloadAction } from "@reduxjs/toolkit";
import type { RootState } from "./index";

interface CounterState {
  token: string;
}

const initialState: CounterState = {
  token: localStorage.getItem("token") as string,
};

export const homeSlice = createSlice({
  name: "home",
  initialState,
  reducers: {
    changeToken: (state, actions) => {
      state.token = actions.payload;
    },
  },
});

export const { changeToken } = homeSlice.actions;

export const selectCount = (state: RootState) => state.home.token;

export default homeSlice.reducer;
